public class Calcu 
{
    public static void main(String[] args) {
        // 显示表头
        System.out.println("i\t\tm(i)");
        System.out.println("-------------------");
        
        // 计算并显示指定i值的m(i)
        for (int i = 1; i <= 901; i += 100) {
            if (i == 1) {
                System.out.printf("%d\t\t%.4f\n", i, computePi(i));
            } else {
                System.out.printf("%d\t\t%.4f\n", i, computePi(i));
            }
        }
    }
    public static double computePi(int i) {
        double sum = 0.0;
        
        for (int k = 1; k <= i; k++) {
            // 计算第k项：(-1)^(k+1) / (2k-1)
            double term = Math.pow(-1, k + 1) / (2 * k - 1);
            sum += term;
        }
        
        return 4 * sum;
    }
}

